<?php
	echo stylesheet_tag(
		'/CreatixLibPlugin/js/dataTable/css/demo_page.css',
		'/CreatixLibPlugin/js/dataTable/css/demo_table_jui.css'
	);
?>

<?php $form = new AlunoForm(); ?>
<h1>Vincular Turma(s) ao Aluno</h1>
<br />
<table class="table table-striped table-bordered table-condensed">
	<thead>
		<tr><th colspan="2">Detalhes do Aluno</th></tr>
	</thead>
	<tbody>
		<tr>
			<th width="150px"><?php echo $form['nm_aluno']->renderLabel() ?></th>
			<td><?php echo $aluno->getNmAluno() ?></td>
		</tr>
		<tr>
			<th><?php echo $form['dt_nascimento']->renderLabel() ?></th>
			<td><?php echo $aluno->getDtNascimento() ?></td>
		</tr>
		<tr>
			<th><?php echo $form['st_aluno']->renderLabel() ?></th>
			<td><?php echo traduzStatus($aluno->getStAluno()) ?></td>
		</tr>
	</tbody>
</table>

<form id="form_aluno" name="form_aluno"
	action="<?php echo url_for('aluno/turmas?id_aluno='.$aluno->getIdAluno()); ?>"
	method="post">
<table class="display" id="dataTable">
	<thead>
		<tr>
			<th></th>
			<th>Turma</th>
			<th>Faixa etária</th>
			<th>Ano</th>
			<th>Período</th>
		</tr>
	</thead>
	<tbody>
	<?php foreach($turmas as $turma): ?>
		<?php foreach($turma->getTurmaAnoLetivo() as $anolet): ?>
		<tr>
			<td width="25px">
				<?php 
					echo checkbox_tag('turma[]', $anolet->getIdTurmaAnoLetivo())
				?>
			</td>
			<td>
				<?php $_tmp = array($turma->getNmTurma(), 'N.'.$turma->getNuTurma(), $turma->getDsTurma())?>
				<?php echo implode(' - ', $_tmp); ?>
			</td>
			<td>
				<?php if ( $anolet->getIdadeInicio() ) :?>de <?php echo $anolet->getIdadeInicio(); endif;?>
				<?php if ( $anolet->getIdadeFim() ) :?>até <?php echo $anolet->getIdadeFim(); endif;?>
			</td>
			<td> 
				<?php echo $anolet->getNuAnoLetivo(); ?>
			</td>
			<td>
				<?php echo $anolet->getPeriodo(false); ?>
			</td>
		</tr>
		<?php endforeach; ?>
	<?php endforeach; ?>
	</tbody>
</table>

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'aluno/list',
			array('class' => 'btn')
		),
		submit_tag(
			':: Salvar ::',
			array('class' => 'btn btn-primary')
		)
	);
?>
</form>

<?php
	echo javascript_include_tag(
		'/CreatixLibPlugin/js/dataTable/js/jquery.dataTables.min.js'
	);
?>

<script type="text/javascript">
$(document).ready(function(){
	System.griddata.dataTableDefault();
});
</script>
